package cn.zh.aop.controller;

import cn.zh.aop.anno.TargetDataSource;
import cn.zh.aop.constant.DataSourceEnum;
import cn.zh.aop.entity.Plan;
import cn.zh.aop.mapper.MasterPlanMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author zh
 */
@RestController
@RequiredArgsConstructor
public class PlanController {

    private final MasterPlanMapper masterPlanMapper;

    @GetMapping("/plan/{id}")
    public Plan getPlan(@PathVariable Long id){
        return masterPlanMapper.selectById(id);
    }

    @GetMapping("/slave/plan/{id}")
    @TargetDataSource(DataSourceEnum.SLAVE)
    public Plan getSlavePlan(@PathVariable Long id){
        return masterPlanMapper.selectById(id);
    }

}
